﻿using System;

namespace DataGeneration
{
    public class Logger
    {
        public enum ELevel {None, Low, High}

        public static bool Commit = true;

        public static ELevel Level = ELevel.Low;

        static Logger()
        {
            //Trace.Listeners.Add(new ConsoleTraceListener());
        }

        protected static void Log(ELevel level, string format, params object[] args)
        {
            if(format.StartsWith("%"))
            {
                var end = format.IndexOf('%', 1);
                if (end > 0)
                {
                    var color = format.Substring(1, end - 1);
                    format = format.Substring(end + 1);
                    ConsoleColor cc;
                    ConsoleColor.TryParse(color, true, out cc);
                    Console.ForegroundColor = cc;
                }
            }
            if (level <= Level)
                Console.WriteLine(format, args);
            Console.ResetColor();
        }

        public static void LogLow(string format, params object[] args)
        {
            Log(ELevel.Low, format, args);
        }

        public static void LogHigh(string format, params object[] args)
        {
            Log(ELevel.High, format, args);
        }
    }
}